{{ '<?php' }}

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class Create{{ class_name }}Table extends Migration
{
	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		// Create the `{{ model_class }}` table
		Schema::create('{{ table_name }}', function(Blueprint $table)
		{
{% for column, definition in columns %}
            $table
{%- if definition.autoincrement is defined and definition.autoincrement == true -%}
        ->increments('{{ column }}');
{% else %}
        {%- if 'string' in definition.type or 'varchar' in definition.type -%}
            ->string('{{ column }}', {{ (definition.type)|replace({'string':'', 'varchar':'', '(':'', ')':''}) }})
        {%- else -%}
        ->{{ definition.type }}('{{ column }}')
        {%- endif -%}
        {%- if definition.nullable is defined and definition.nullable == true -%}
            ->nullable()
        {%- endif -%}
        ;
{% endif %}

{%- endfor %}
{% if timestamps == true %}
            $table->timestamps();
{% endif %}
{% if softdelete == true %}
            $table->softDeletes();
{% endif %}
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        // Delete the `{{ model_class }}` table
        Schema::drop('{{ table_name }}');
    }
}
